<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [1, 2, 3, 4, 5];
      // 更方便的find方法，找到返回钙元素，找不到返回undefined
      let flag = arr.find((i) => i == 7);
      console.log(flag);

      // find主要用于引用类型的查找

      let lessons = [
        {
          name: "js",
        },
        {
          name: "css",
        },
        {
          name: "mysql",
        },
      ];
      let status = lessons.find((i) => i.name == "css");
      console.log(status);
      // 当然了，如果想要获取索引可以使用findIndex
      let index = lessons.findIndex((i) => i.name == "js");
      console.log(index);
    </script>
  </body>
</html>
